Skip to content

gh-133678: Add a banner to C API doc to recommend 3rd party tools#133679

Closed
vstinner wants to merge 7 commits into
python:mainfrom
vstinner:c_api_banner
Closed

gh-133678: Add a banner to C API doc to recommend 3rd party tools#133679
vstinner wants to merge 7 commits into
python:mainfrom
vstinner:c_api_banner

Conversation

@vstinner

@vstinner vstinner commented May 8, 2025

Copy link
Copy Markdown
Member

@vstinner

vstinner commented May 8, 2025

Copy link
Copy Markdown
Member Author

Banner added to all pages (the gray note):

Screenshot 2025-05-08 at 17-50-23 Python_C API Reference Manual — Python 3 15 0a0 documentation


Link to this new section:

Screenshot 2025-05-08 at 17-51-19 Introduction — Python 3 15 0a0 documentation

@zooba

zooba commented May 8, 2025

Copy link
Copy Markdown
Member

I think we'll need a bit more nuance in here, explaining why we still have a C API at all if we're telling people not to use it (obvious to us, not obvious to someone who happens to be reading these docs for the first time).

@efimov-mikhail

Copy link
Copy Markdown
Member

I think we'll need a bit more nuance in here, explaining why we still have a C API at all if we're telling people not to use it (obvious to us, not obvious to someone who happens to be reading these docs for the first time).

Totally agree. For example, I've personally taken a lot of information from the last discuss thread. It seems to be very useful to document these nuances in concise manner.

@zooba

zooba commented May 8, 2025

Copy link
Copy Markdown
Member

I also think we need to be careful to indicate that these are not supported by the same people who maintain Python, and issues need to be raised with the projects directly.

@philthompson10

Copy link
Copy Markdown

...and, by implication, other abstractions are not recommended?

@vstinner

vstinner commented May 8, 2025

Copy link
Copy Markdown
Member Author

@zooba: I elaborated the rationale a little bit in the "Recommended third party tools" section. Feel free to propose better wording, I'm not good to write documentation :-)

https://cpython-previews--133679.org.readthedocs.build/en/133679/c-api/intro.html#recommended-third-party-tools

@vstinner

vstinner commented May 8, 2025

Copy link
Copy Markdown
Member Author

...and, by implication, other abstractions are not recommended?

It's not the case. Did I miss some major abstractions in my list?

@philthompson10

Copy link
Copy Markdown

The list is at least inconsistent with https://docs.python.org/dev/faq/extending.html#writing-c-is-hard-are-there-any-alternatives

However my problem is with the word recommended which implies some sort of official blessing which would put new (possibly better) abstractions at a disadvantage and implies some quality control process. I'd prefer something like established or commonly used.

@efimov-mikhail

Copy link
Copy Markdown
Member

However my problem is with the word recommended which implies some sort of official blessing which would put new (possibly better) abstractions at a disadvantage and implies some quality control process.

IMO, this is actually a recommended API for the most of the projects. There is no direct implication that other abstraction could not be better in future. In fact, it's not a problem to add a new entry to this list, if some project had proven as a well-established alternative.

But at the moment a maintainer of some project can use C API directly or through some binding. And CPython developers encourage that maintainer to use the latter.

Comment thread Doc/c-api/intro.rst Outdated
Comment thread Doc/c-api/intro.rst Outdated
Comment thread Doc/c-api/intro.rst Outdated
vstinner and others added 3 commits May 9, 2025 07:44
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
@vstinner vstinner marked this pull request as ready for review May 9, 2025 05:55
@vstinner vstinner requested review from 1st1, AA-Turner and hugovk as code owners May 9, 2025 05:55
@vstinner vstinner changed the title gh-133678: Add a banner to C API doc to recommend tools gh-133678: Add a banner to C API doc to recommend 3rd party tools May 9, 2025
@ZeroIntensity ZeroIntensity added docs Documentation in the Doc dir topic-C-API labels May 9, 2025
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs May 9, 2025
Comment thread Doc/tools/extensions/c_annotations.py Outdated

@ncoghlan ncoghlan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested an adjustment to the banner wording. The intro to https://docs.python.org/3/extending/index.html should also be updated (potentially replacing the existing 3rd party tool list there and cross-referencing it from the C API intro rather than making a new separate list in the C API docs intro)

Comment on lines +268 to +269
class CAPIToolsBanner(SphinxDirective):
"""CAPI Tools banner."""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From an implementation perspective, it would be better to use an .. include:: directive rather than adding custom code here.

I don't have a strong opinion on the banner in general, but I wonder if adding it to every page is a bit much? I defer to the C API group for deliberations here, though.

A

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've had the existing note in the extending/embedding intro for a long time, but it doesn't really work for anyone coming in from a deep link (including search results). A banner seems like a plausible improvement.

Given the possibility of anchor targets dropping people in well down the pages, though, I do wonder if a hovering banner like the ones added to finalised PEPs might be a better technical approach.

Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
@brettcannon brettcannon removed their request for review May 12, 2025 19:50
@kumaraditya303 kumaraditya303 removed their request for review May 21, 2025 09:39
@vstinner

Copy link
Copy Markdown
Member Author

@encukou is against the banner, so I wrote a simpler PR just to add a section to the C API Introduction, and modify existing text to point to this section: #134526.

@vstinner vstinner closed this May 22, 2025
@vstinner vstinner deleted the c_api_banner branch May 22, 2025 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

8 participants